import dayjs from "dayjs";

export function useColumns() {
  const getVarianceNum = row => {
    let count = Number(row.postCount || 0) - Number(row.atCount || 0);
    return String(count);
  };

  // 库存盘点
  const kcpdColumns: TableColumnList = [
    {
      label: "业务日期",
      prop: "businessDate",
      minWidth: 120,
      formatter: ({ businessDate }) => dayjs(businessDate).format("YYYY-MM-DD")
    },
    {
      label: "盘点时库存",
      prop: "atCount",
      minWidth: 120
    },
    {
      label: "盘点后库存",
      prop: "goodsAmount",
      minWidth: 130,
      cellRenderer: ({ row }) => (
        <el-input-number
          min={0}
          step={1}
          step-strictly
          v-model={row.postCount}
          placeholder="请输入"
          style="width: 100%"
        />
      )
    },
    {
      label: "差异数量",
      prop: "varianceNum",
      minWidth: 120,
      formatter: row => getVarianceNum(row)
    }
  ];

  return {
    kcpdColumns
  };
}
